package com.mkz.core.log.event;

import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import com.mkz.admin.entity.SysLog;
import com.mkz.admin.feign.RemoteLogService;
import com.mkz.core.common.constant.SecurityConstants;

import lombok.AllArgsConstructor;


/**
 * @author XXXXXX
 * 异步监听日志事件
 */
@AllArgsConstructor
public class SysLogListener {
	private final RemoteLogService remoteLogService;

	@Async
	@Order
	@EventListener(SysLogEvent.class)
	public void saveSysLog(SysLogEvent event) {
		SysLog sysLog = (SysLog) event.getSource();
		remoteLogService.saveLog(sysLog, SecurityConstants.FROM_IN);
	}
}
